import Viewer from 'viewerjs';
import 'viewerjs/dist/viewer.css';
let viewer
export default {
    vInit() {
        // 创建一个div
        let div = document.createElement('div');
        div.id = 'viewer-img';
        div.style.display = 'none';
        document.body.appendChild(div);
    },
    vShow(img) {
        if (viewer) {
            viewer.destroy();
        }
        if (img.length == 0) {
            return;
        }
        let main = document.getElementById('viewer-img');
        main.innerHTML = `<img data-source="${img}" />`;

        // 创建一个viewer对象
        viewer = new Viewer(document.getElementById('viewer-img'), {
            url: 'data-source',
            keyboard: false,
            navbar: false,
            rotatable: false,
            scalable: false,
            slideOnTouch: false,
            toggleOnDblclick: false,
            toolbar: false,
            tooltip: false,
        });
        // 显示图片
        viewer.show();
    },
}
